home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Tele
/
M
/
MFNotify.cpt
/
MFNotify.c
next >
Wrap
C/C++ Source or Header
|
1989-11-09
|
5KB
|
260 lines
#include "MacTypes.h"
#include "QuickDraw.h"
#include "DeviceMgr.h"
#include "EventMgr.h"
#include "FileMgr.h"
#include "MemoryMgr.h"
#include "ResourceMgr.h"
#include "WindowMgr.h"
#include "SetUpA4.h"
typedef struct
{
long thenum[234];
} NumVar,*NumVarPtr;
typedef struct
{
Byte thestr[234][134];
} Strings,*StrVarPtr;
typedef struct
{
Byte theparam[8350];
} RedParam,*RedPtr;
typedef struct
{
Byte theval[20];
} Byte20,*Byte20Ptr;
typedef struct
{
Byte data[1024];
} Buff1K,*Ptr1K;
typedef struct
{
Byte data[2048];
} Buff2K,*Ptr2K;
typedef struct
{
Byte thechar[256][2];
} Filter,*FilterPtr;
typedef struct
{
Byte YesNoFlag;
Byte ErrorFlag;
} FlagRec,*FlagPtr;
typedef struct
{
Byte thepath[123];
} Byte123,*Ptr123;
typedef struct
{
unsigned short red;
unsigned short green;
unsigned short blue;
} RGBColor;
typedef struct
{
NumVarPtr Numeric;
StrVarPtr String;
RedPtr RedParams;
Ptr Reserved1;
long Reserved2;
long Reserved3;
long Reserved4;
short Reserved5;
ParmBlkPtr UserBlock1;
ParmBlkPtr UserBlock2;
ParmBlkPtr SerialIn;
ParmBlkPtr SerialOut;
Byte20Ptr RadioGroup;
Byte20Ptr CheckBox;
Ptr1K Buffer1K;
Ptr2K Buffer2K;
FilterPtr TFilter;
FilterPtr FFilter;
FilterPtr PFilter;
FlagPtr Flags;
Ptr123 RecPath;
RGBColor Forecolor;
RGBColor Backcolor;
RGBColor Hilcolor;
RGBColor SBfore;
RGBColor SBback;
RGBColor SBhil;
RGBColor Phonefore;
RGBColor Phoneback;
RGBColor Phonehil;
RGBColor Indfore;
RGBColor Indback;
RGBColor Rlefore;
RGBColor Rleback;
WindowPeek RedsWindow;
short DoUpdate;
Rect TransferRect;
short Version;
} RParam,*RPtr;
/* Globals used in this RCMD */
NMRec *therec;
EventRecord event;
ParamBlockRec volblock;
WindowPtr whichWin;
Handle thesnd;
unsigned long sresize;
Handle thesicn;
short idnum;
/*
Install MultiFinder Notification Manager alert.
Changes value of S%,I%, and A%
Text for dialog box is in T$.
S% = 0, use no sound
S% < 0, use BeepSound
S% > 0, play 'snd ' resource ID number S%.
For debugging purposes:
if (S% > 0) S% returns 0 if no error, 1 if not enough free memory to hold
'snd ' resource, or 2 if 'snd ' resource not found.
I% = 0, use no small icon in Apple menu
I% < 0, use White Knight small icon in Apple menu
I% > 0, use 'SICN' resource ID number I%.
For debugging purposes:
if (I% > 0) I% returns 0 if no error, 1 if not enough free memory to hold
'SICN' resource, or 2 if 'SICN' resource not found.
A% holds the result code of the MultiFinder Notification Manager install attempt.
*/
pascal void ResponseProc();
/* Start of code resource */
pascal void main(params)
RPtr params;
{
RememberA0();
SetUpA4();
thesnd = thesicn = 0L;
therec = (NMRec *)NewPtr(sizeof(NMRec));
therec->nmMark = 1;
therec->nmStr = params->String->thestr[19];
therec->nmResp = ResponseProc;
therec->qType = 8;
therec->nmRefCon = 1;
if (params->Numeric->thenum[8] == 0) therec->nmSIcon = 0L;
else
{
if (params->Numeric->thenum[8] < 0) idnum = 8000; else idnum = (int)params->Numeric->thenum[8];
SetResLoad(0);
thesicn = (Handle)GetResource((long)'SICN',idnum);
if (ResError())
{
therec->nmSIcon = 0L;
params->Numeric->thenum[8] = 2;
goto CONTINUE;
}
sresize = SizeResource(thesicn);
SetResLoad(1);
ResrvMem(sresize);
if (MemError() != 0)
{
therec->nmSIcon = 0L;
params->Numeric->thenum[8] = 1;
goto CONTINUE;
}
LoadResource(thesicn);
HLock(thesicn);
params->Numeric->thenum[8] = 0;
therec->nmSIcon = thesicn;
}
CONTINUE:
if (params->Numeric->thenum[18] == -1L) therec->nmSound = (Handle)-1L;
if (params->Numeric->thenum[18] == 0L) therec->nmSound = 0L;
if (params->Numeric->thenum[18] > 0)
{
SetResLoad(0);
thesnd = (Handle)GetResource((long)'snd ',(int)params->Numeric->thenum[18]);
if (ResError())
{
therec->nmSound = (Handle)-1L;
params->Numeric->thenum[18] = 2;
goto CONT2;
}
sresize = SizeResource(thesnd);
SetResLoad(1);
ResrvMem(sresize);
if (MemError() != 0)
{
therec->nmSound = (Handle)-1L;
params->Numeric->thenum[18] = 1;
goto CONT2;
}
LoadResource(thesnd);
HLock(thesnd);
params->Numeric->thenum[18] = 0;
therec->nmSound = thesnd;
}
CONT2:
if (params->Numeric->thenum[0] = NMInstall(therec))
{
SysBeep(60);
goto EXIT;
}
while (therec->nmRefCon) DoEvent();
NMRemove(therec);
EXIT:
if (thesnd)
{
HUnlock(thesnd);
DisposHandle(thesnd);
}
if (thesicn)
{
HUnlock(thesicn);
DisposHandle(thesicn);
}
DisposPtr(therec);
RestoreA4();
}
pascal void ResponseProc(nmReqPtr)
NMRec *nmReqPtr;
{
nmReqPtr->nmRefCon = 0;
}
DoEvent()
{
integer wheremouse,OSerr;
SystemTask();
if (!GetNextEvent(-1,&event)) return;
switch (event.what)
{
case diskEvt:
volblock.ioParam.ioVRefNum = (short)(event.message);
OSerr = PBMountVol(&volblock);
break;
case mouseDown:
wheremouse = FindWindow(event.where,&whichWin);
switch (wheremouse)
{
case inSysWindow:
SystemClick(&event,whichWin); /* system event */
break;
}
break;
}
}